package com.jie.jie.mvp.ui;

import android.support.v7.widget.LinearLayoutManager;

import com.jaydenxiao.common.base.BaseActivity;
import com.jaydenxiao.common.v.recyclerview.SwipeRecyclerView;
import com.jie.jie.R;
import com.jie.jie.mvp.adpter.MeiRvAdapter;
import com.jie.jie.mvp.contract.Meicontract;
import com.jie.jie.mvp.model.MeiModel;
import com.jie.jie.mvp.model.MeiziBean;
import com.jie.jie.mvp.persenter.MeiPresenter;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;

public class Meimei extends BaseActivity<MeiPresenter, MeiModel> implements Meicontract.View {


    @Bind(R.id.mei_rv)
    SwipeRecyclerView meiRv;
    private MeiRvAdapter adapter;
    private int page = 1;
    private List<MeiziBean> datas;

    @Override
    public int getLayoutId() {
        return R.layout.activity_meimei;
    }

    @Override
    public void initPresenter() {
        mPresenter.setVM(this,mModel);
    }

    @Override
    public void initView() {
        mPresenter.getMEizi(page);
        datas = new ArrayList<>();
        adapter = new MeiRvAdapter(this, datas);
        meiRv.getRecyclerView().setLayoutManager(new LinearLayoutManager(this));
        meiRv.setAdapter(adapter);
        meiRv.setOnLoadListener(new SwipeRecyclerView.OnLoadListener() {
            @Override
            public void onRefresh() {

            }

            @Override
            public void onLoadMore() {
                page += 1;
                mPresenter.getMEizi(page);

            }
        });
    }

    @Override
    public void returnMeizi(List<MeiziBean> meiziBeen) {
        meiRv.stopLoadingMore();
        datas.addAll(meiziBeen);
        adapter.notifyDataSetChanged();
    }

    @Override
    public void returnMizi(List<MeiziBean> meiziBeen) {

    }

    @Override
    public void showLoading(String title) {

    }

    @Override
    public void stopLoading() {

    }

    @Override
    public void showErrorTip(String msg) {

    }

}
